package io.gitee.zhangbinhub.admin.log.conf

import io.gitee.zhangbinhub.admin.common.constant.RouteConstant
import io.gitee.zhangbinhub.admin.log.consumer.RouteLogConsumerProcess
import org.springframework.boot.autoconfigure.AutoConfigureBefore
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.cloud.stream.config.BindingServiceConfiguration
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

/**
 * @author zhang by 10/09/2019
 * @since JDK 11
 */
@Configuration(proxyBeanMethods = false)
@AutoConfigureBefore(BindingServiceConfiguration::class)
class RouteLogConfiguration {
    @Bean(RouteConstant.ROUTE_LOG_CONSUMER)
    @ConditionalOnMissingBean(name = [RouteConstant.ROUTE_LOG_CONSUMER])
    fun routeLogConsumer(routeLogConsumerProcess: RouteLogConsumerProcess): (String) -> Unit {
        return { routeLogConsumerProcess.accept(it) }
    }
}